/**
 * Created by aa on 2016/8/11.
 */
$(function(){
    $('#test1').on('click',function(){
        alert(injectedObject.toString('sdf'));
        alert('骚年你成功了');
    });

    $('#test2').on('click',function(){
        setupWebViewJavascriptBridge(function(bridge) {

            bridge.callHandler('test', "{'key':'value'}", function responseCallback(responseData) {
                alert('骚年你成功了');
            })
        });
    });
});

function setupWebViewJavascriptBridge(callback) {
    if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
    if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
    window.WVJBCallbacks = [callback];
    var WVJBIframe = document.createElement('iframe');
    WVJBIframe.style.display = 'none';
    WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
    document.documentElement.appendChild(WVJBIframe);
    setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
}